package cn.fourhundredandeighteen.utill;

/**
 * @description:
 * @author: liuyongqi
 * @time: 2020/12/15
 */
public class ResultGenerator {
    private final static int SUCCESS_CODE = 2000;
    private final static int ERROR_CODE = 500;
    private final static String SUCCESS_MASSAGE = "SUCCESS";
    private final static String ERROR_MASSAGE = "ERROR";

    public static Result successResult() {
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setMassage(SUCCESS_MASSAGE);
        return result;
    }

    public static Result successResult(Object data) {
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setMassage(SUCCESS_MASSAGE);
        result.setData(data);
        return result;
    }

    public static Result successResult(String massage, Object data) {
        Result result = new Result();
        result.setCode(SUCCESS_CODE);
        result.setMassage(SUCCESS_MASSAGE);
        result.setData(data);
        result.setMassage(massage);
        return result;
    }

    public static Result errorResult() {
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMassage(ERROR_MASSAGE);
        return result;
    }

    public static Result errorResult(Object data) {
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMassage(ERROR_MASSAGE);
        result.setData(data);
        return result;
    }

    public static Result errorResult(String massage, Object data) {
        Result result = new Result();
        result.setCode(ERROR_CODE);
        result.setMassage(ERROR_MASSAGE);
        result.setData(data);
        result.setMassage(massage);
        return result;
    }
}
